#include "./client/MessageClient.h"
#include "../test_type.h"
#include <iostream>
#include <memory>
#include <thread>
#include <string>

using namespace std;
using namespace client;

#ifdef TEST_MESSAGE_CLIENT
int main()
{
	shared_ptr<MessageClient> c(new MessageClient());
	string ip; int port = 0;
	cout << "ip:";
	cin >> ip;
	cout << "port:";
	cin >> port;

	thread th(std::bind(&MessageClient::Run, c.get()));

	c->Connect(ip, port);

	string getstr;
	while (true)
	{
		for (auto msg = string("---------------------------------------------------------"); 
			msg.size() > 0; msg = c->GetMessage())
		{
			cout << msg << endl;
		}

		cout << "please input:";
		cin >> std::skipws >> getstr;
		if(getstr == "quit") exit(0);

		c->Write(getstr.data(), getstr.size());
	}


	th.join();
	return 0;
}

#endif